<template>
  <div class="NewsList">
    <myheader title="图片资讯">
      <template #left>
        <div @click="$router.go(-1)">
          <van-icon name="arrow-left" />
          返回
        </div>
      </template>
    </myheader>
    <div
      class="news"
      v-for="item in news"
      :key="item.id"
      @click="$router.push({ path: `/newsDetial/${item.id}` })"
    >
      <div class="left">
        <img :src="item.img_url" />
      </div>
      <div class="right">
        <p class="content">{{ item.title }}</p>
        <div class="time">
          发表时间：
          {{ item.add_time | newsDateFilter }}
          <p>点击：{{ item.click }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getNewsList } from "../../Api/post";
import myheader from "../../components/myheader";
import { newsDateFilter } from "@/utils/filter";
export default {
  data() {
    return {
      news: [],
    };
  },
  components: { myheader },
  filters: {
    newsDateFilter,
  },
  async mounted() {
    let res = await getNewsList();
    // console.log(res);

    this.news = res.data.message;
  },
};
</script>
<style lang="less" scoped>
.van-icon {
  vertical-align: text-bottom;
}
.news {
  display: flex;
  height: 75px;
  padding: 0 10px;
  margin-top: 10px;
  border-bottom: 1px solid #ccc;
  .left {
    flex: 1;
    width: 70px;
    height: 70px;
    margin: 0 10px;
    img {
      width: 100%;
    }
  }
  .right {
    flex: 5;
    width: 70px;
    height: 70px;
    font-size: 14px;
    color: rgb(119, 119, 119);
    text-align: left;
    .content {
      display: block;
      font-size: 14px;
      line-height: 24px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .time {
      display: flex;
      color: #61bdff;
      margin-top: 8px;
      p {
        position: absolute;
        right: 15px;
      }
    }
  }
}
</style>